Skip to content

chore(telemetry): normalize telemetry property keys to snake_case#1196

Merged
7Sageer merged 1 commit into
mainfrom
chore/normalize-telemetry-keys
Jun 29, 2026
Merged

chore(telemetry): normalize telemetry property keys to snake_case#1196
7Sageer merged 1 commit into
mainfrom
chore/normalize-telemetry-keys

Conversation

@7Sageer

@7Sageer 7Sageer commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This is internal telemetry hygiene; the motivation is in the next section.

Problem

Telemetry property keys had drifted into an inconsistent mix of camelCase and
snake_case across events, and a few events carried redundant or sparse fields:

  • compaction_finished / compaction_failed and micro_compaction_finished
    used camelCase (tokensBefore, compactedCount, retryCount, …) while the
    rest of the telemetry surface (subagent_name, run_in_background,
    duration_ms, …) is snake_case.
  • update_prompted emitted both current/latest and
    current_version/target_version for the same values.
  • Client attribution on session_started was a sparse key set (empty fields
    omitted), so the two producers (daemon core-impl and single-process
    kimi-harness) could emit differently-shaped events.

Telemetry is untyped (TelemetryProperties = Record<string, …>), so none of
this is caught by the compiler; the contract lives in the downstream consumers.
Keeping the key schema consistent and stable is what makes those consumers
tractable.

What changed

  • Renamed the remaining camelCase telemetry keys to snake_case
    (tokens_before, tokens_after, compacted_count, retry_count,
    thinking_level, error_type, input_tokens / output_tokens, and the
    micro-compaction config / effect keys).
  • Emit a fixed client-attribution key set (client_id / client_name /
    client_version / ui_mode, null when the client did not provide a field)
    from both session_started producers so they share one schema.
  • Removed the duplicate current / latest keys on update_prompted and the
    redundant ui_mode on server_started (the server's boot UI mode is now
    covered by the client-attribution ui_mode).
  • Additive: login now carries method: 'oauth' (matching the existing
    method: 'api_key' path), and question_answered carries an answered
    count.

A few fields changed shape, not just name, worth flagging explicitly:

  • compaction_finished no longer emits the custom instruction, and the
    per-component token breakdown (inputCacheRead / inputCacheCreation) was
    folded into a single input_tokens (= inputTotal).
  • The tool / video_upload error event moved from error (full message) to
    error_type (error class name), matching the convention already used by
    crash, api_error, and compaction_failed (low-cardinality type on
    telemetry; the message stays on hooks / logs).

The persisted apply_compaction record fields (CompactionResult.tokensBefore
etc.) are intentionally left camelCase — they are consumed by external
projectors and are a separate channel from telemetry.

Compatibility

This renames and remaps telemetry property keys that downstream dashboards and
alerts may reference. Producers and consumers should be coordinated before this
lands.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works. (Existing telemetry tests were updated to assert the new schema.)
  • Ran gen-changesets skill, or this PR needs no changeset. (Telemetry-only change — no changeset.)
  • Ran gen-docs skill, or this PR needs no doc update. (Internal telemetry schema — no user-facing docs to update.)

- Rename camelCase telemetry keys to snake_case on compaction_finished, compaction_failed, micro_compaction_finished, and the tool error event (tokens_before, tokens_after, compacted_count, retry_count, thinking_level, error_type, input_tokens/output_tokens, and the micro compaction config/effect keys).

- Emit a fixed client-attribution key set (client_id/name/version/ui_mode, null when absent) from both session_started producers (core-impl and kimi-harness) so they share a stable schema.

- Drop the duplicate current/latest keys on update_prompted and the redundant ui_mode on server_started.

- Additive fields: login.method=oauth and question_answered.answered.

Telemetry-only change; no changeset.
@changeset-bot

changeset-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9475366

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 29, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@9475366
npx https://pkg.pr.new/@moonshot-ai/kimi-code@9475366

commit: 9475366

@7Sageer 7Sageer merged commit 10ffb7d into main Jun 29, 2026
10 checks passed
@7Sageer 7Sageer deleted the chore/normalize-telemetry-keys branch June 29, 2026 09:40
7Sageer added a commit to 7Sageer/kimi-code that referenced this pull request Jun 29, 2026
Resolve conflicts in compaction telemetry: adopt the snake_case telemetry keys from main (MoonshotAI#1196) while keeping this branch's single-round compaction design that retains user messages. 'round' is hard-coded to 1 since this branch compacts in a single round; affected test assertions are updated to match the snake_case keys and this branch's token counts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant